package server

import (
	"context"
	"gitee.com/smallow/srpc/infrastructure/business"
	"gitee.com/smallow/srpc/infrastructure/model"
	"gitee.com/smallow/srpc/infrastructure/proto/pb"
)

type ApiService struct{}

func (ApiService) CreateApi(ctx context.Context, req *pb.CreateApiReq) (*pb.CreateApiResp, error) {
	apiID, err := business.CreateApi(&model.Api{
		Name:  req.Name,
		Path:  req.Path,
		State: 1,
		AppID: req.AppID,
		Group: req.Group,
	})
	if apiID != 0 && err == nil {
		return &pb.CreateApiResp{
			ApiID: int32(apiID),
		}, nil
	} else {
		return &pb.CreateApiResp{ApiID: 0}, err
	}
}

func (ApiService) FindUserApiID(ctx context.Context, req *pb.FindUserApiReq) (*pb.FindUserApiResp, error) {
	panic("implement me")
}

func (ApiService) UpdateUserApiCache(ctx context.Context, req *pb.FindUserApiReq) (*pb.FindUserApiResp, error) {
	panic("implement me")
}
